<style>
.content-group {background:#fff;border-radius: 0.5rem;margin-bottom:0.39rem}
.arrow-text {
	display:inline-block;padding:0.1rem 0.3rem;color:#fff;font-size:0.5rem;background:#ff4e2c;border-radius:0.1rem;
}
.arrow-right {
  display:inline-block;
  width:0px;
  height:0px;
  border-bottom:5px solid transparent;  /* left arrow slant */
  border-top:5px solid transparent; /* right arrow slant */
  border-left:5px solid #ff4e2c; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
  margin-bottom:-1px
}
.fui-navbar .cartbtn {padding-right:0.3rem;background:#fff;opacity:1}
.fui-navbar .buybtn  {padding-left:0.3rem;background:#fff}
.fee-tag-nav, .fee-tagup-nav, .fee-disabled-nav {border-radius:1rem;height:2rem;line-height:2rem;color:#fff;width:100%;font-weight:400;font-size:0.7rem;margin:0.2rem 0;padding:0 0.2rem}
.fee-tagup {background:{{main.syscolor || 'red'}};color:#fff;width:auto;font-weight:400;font-size:0.55rem}
.fee-tag-nav {background:{{main.syscolor || 'red'}}; opacity: 0.58;}
.fee-tagup-nav {background:{{main.syscolor || 'red'}};}
</style>
<div class="fui-page fui-page-current page-goods-list">
<div class='fui-content'>
		<div style="padding:0 0.5rem">
		<div ng-include="sys_html('shop/_kai')"></div>
		<div ng-include="sys_html('common/_copyright',true)"></div>
		</div>
</div>
<div class="fui-navbar-tip" ng-if="pagedata.pluginset.open_tips==1"><i class="icon icon-information" style="font-size:0.6rem;color:red"></i> {{pagedata.pluginset.tips}}</div>
<div class="fui-navbar order-create-checkout">
    <a href="javascript:;" class="nav-item total" style="text-align:left;padding-left:0.5rem">
        金额:<span class="text-danger bigprice">￥ 
			<span class="totalprice" style="font-size:1.2rem">{{pagedata.post.endprice || '0.00'}}</span>
		</span>
    </a>
    <a href="javascript:;" class="nav-item btn buybtn" ng-click="post(pagedata.post,'jy_invoice/kai/post/')" >
		<div class="fee-tagup-nav">
			立即开票
		</div>
	</a>
</div>
<div ng-if="pagedata.modal_address==1" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="padding-bottom:2.5rem">
		<i class="closed icon icon-close" style="color:red;top:0.3rem" ng-click="pagedata.modal_address=0"></i>
		<div class="fui-list-group modal-swiper-y" style='margin-top:5px;background:#fff;'>
			<div class="fui-list address-item" ng-repeat="item in pagedata.address_list">
				<div class="fui-list-inner">
					<div class="title" ng-click="pagedata.change_address(item)"><span class='realname'>{{item.name}}</span> <span class='mobile'>{{item.mobile}}</span></div>
					<div class="text" ng-click="pagedata.change_address(item)"><span class='address'>{{item.pcd.province}} {{item.pcd.city}} {{item.pcd.district}} {{item.address}}</span></div>
					<div class='bar' style="line-height:1.4">
						<span class='pull-right'>
							<a class="external" href="javascript:;" ng-click="pagedata.edit_address=1;pagedata.address=item;pagedata.isaddaddress=0">
							<i class='icon icon-bianji'></i> 编辑
							</a>
							<a class='external' href="javascript:;" ng-click="pagedata.del_address($index)">
							<i class='icon icon-shanchu'></i> 删除
							</a>
						</span>
					</div>
				</div>
			</div>
		</div>
		<div class='fui-navbar'>
			<a class="nav-item btn btn-danger external" ng-click="pagedata.edit_address=1;pagedata.post.address.address='';pagedata.isaddaddress=1"><i class="icon icon-tianjia" style="font-size:0.8rem"></i> 添加地址</a>
		</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.edit_address" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<div class='fui-cell-group modal-swiper-y' style="border-radius: 0.5rem;margin-top:0;height:auto;max-height:20rem;padding-bottom:2.5rem">
				<div ng-if="pagedata.nowtype==1" class="fui-cell">
					<div class="fui-cell-label" style="width:100px;font-size:0.8rem">编辑地址</div>
					<div class='fui-cell-info'></div>
					<div class="fui-cell-remark" ng-if="pagedata.openid && pagedata.isaddaddress==1"><span ng-click="pagedata.openAddress()">添加微信地址</span></div>
				</div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>收件人</div>
                    <div class='fui-cell-info'><input type="text" ng-model="pagedata.address.name" placeholder="收件人" class="fui-input"/></div>
                </div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>联系电话</div>
                    <div class='fui-cell-info'><input type="tel" ng-model="pagedata.address.mobile" placeholder="联系电话"  class="fui-input"/></div>
                </div>
                <div class="fui-cell">
					<div class="fui-cell-label ">地区</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.address.pcd.province" class="form-control tpl-province">
						<option value="" selected="selected">省份</option>
						<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.address.pcd.province==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.address.pcd.city" class="form-control tpl-city">
						<option value="" selected="selected">城市</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.address.pcd.province]" value="{{value}}" ng-selected="pagedata.address.pcd.city==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.address.pcd.district" class="form-control tpl-district">
						<option value="" selected="selected">区县</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.address.pcd.province][pagedata.address.pcd.city]" value="{{value}}" ng-selected="pagedata.address.pcd.district==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.address.pcd.street" class="form-control tpl-district">
						<option value="" selected="selected">街道</option>
						<option ng-repeat="value in pagedata.province[pagedata.address.pcd.province][pagedata.address.pcd.city][pagedata.address.pcd.district]" value="{{value}}" ng-selected="pagedata.address.pcd.street==value">{{value}}</option>
						</select>
					</div>
				</div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>详细地址</div>
                    <div class='fui-cell-info'><input type="text" ng-model="pagedata.address.address" placeholder='街道，楼牌号等'  class="fui-input"/></div>
                </div>
            </div>
			<div class="fui-navbar">
				<a href="javascript:;" ng-click="pagedata.add_address();" class="nav-item btn btn-danger confirmbtn">确定</a>
			</div>
			<i ng-click="pagedata.edit_address=false" class="closed icon icon-cuowu"></i>
		</div>
	</div>
</div>
</div>
<script>
//提交
scope.pagedata.topost=function(msg){
	scope.post_json('core/member.address/post/',scope.pagedata.address,function(res){
		scope.pagedata.post.addressid =res;
		scope.pagedata.edit_address=false;
		scope.pagedata.modal_address=0;
		scope.$evalAsync();
	});
}
scope.pagedata.add_address=function(){
	scope.pagedata.address.res=1
	if(scope.pagedata.isaddaddress==1){
		scope.pagedata.address.id=0;
	}
	scope.pagedata.post.toaddress=scope.pagedata.address;
	scope.post_json('core/member.address/post/',scope.pagedata.address,function(res){
		scope.pagedata.post.addressid =res;
		scope.pagedata.edit_address=false;
		scope.pagedata.modal_address=0;
		scope.$evalAsync();
	});
}
scope.pagedata.change_address=function(res){
	scope.pagedata.post.toaddress=res;
	scope.pagedata.post.addressid=res.id;
	scope.pagedata.modal_address=0;
	scope.$evalAsync();
}
scope.pagedata.get_addresslist=function(){
	scope.get('core/member.address/list/type='+scope.pagedata.nowtype,function(res){
		scope.pagedata.address_list=res.list;
		scope.pagedata.modal_address=1;
		scope.$evalAsync();	
	});
}
scope.pagedata.del_address=function(index){
	var id =scope.pagedata.address_list[index].id
	scope.get('core/member.address/del/id='+id+'&get=1',function(res){
		scope.pagedata.address_list.splice(index,1);
		scope.message('删除成功');
		scope.$evalAsync();
	});
}
scope.pagedata.openAddress=function (){
	wx.openAddress({
		  success: function (res) {
			scope.pagedata.address={}
			scope.pagedata.address.name = res.userName; // 收货人姓名
			scope.pagedata.address.pcd={}
			scope.pagedata.address.pcd.province = res.provinceName; // 国标收货地址第一级地址（省）
			scope.pagedata.address.pcd.city = res.cityName; // 国标收货地址第二级地址（市）
			scope.pagedata.address.pcd.district = res.countryName; // 国标收货地址第三级地址（国家）
			scope.pagedata.address.address = res.detailInfo; // 详细收货地址信息
			scope.pagedata.address.mobile = res.telNumber; // 收货人手机号码
			scope.$evalAsync();
		  },
		  fail: function (res) {
			console.log('fail');console.log(res)
		  }
	});
}
scope.pagedata.getprovince=function(){
	scope.get('core/member.set/getprovince/',function(res){
		scope.pagedata.province=res.province;
		scope.$evalAsync();
	});
}
scope.pagedata.getprovince();
</script>